import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yi_shop/components/coupon/painter.dart';
import 'package:yi_shop/utils/colors.dart';
import 'package:yi_shop/utils/styles.dart';

class HomeTextileController extends GetxController {

}

class HomeTextileView extends GetView<HomeTextileController> {
  const HomeTextileView({super.key});

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      padding: EdgeInsets.only(bottom: 20.h),
      child: Column(
        children: [
          ...appendWidget(),
        ],
      ),
    );
  }

  List<Widget> appendWidget() {
    List<Widget> list = [];
    for (var i = 0; i < 10; i++) {
      list.add(Container(
        alignment: Alignment.center,
        margin: const EdgeInsets.only(top: 15),
        child: Container(
          width: 360,
          height: 100,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(5.r),
            color: Colors.white,
          ),
          child: CustomPaint(
            painter: MyCustomPainter(),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  width: 100,
                  alignment: Alignment.center,
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(5.r),
                    child: CachedNetworkImage(
                      imageUrl:
                      'https://img.alicdn.com/img/i4/116609430/O1CN01Lfwqz42JWzcklZ8VH_!!0-saturn_solar.jpg_360x360xzq75.jpg_.webp',
                      width: 65,
                      height: 65,
                      fit: BoxFit.fill,
                    ),
                  ),
                ),
                Expanded(
                    child: Container(
                      padding: EdgeInsets.only(
                        left: 2.w,
                      ),
                      child: Column(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: Text(
                              '普拉蒂旗舰店',
                              style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                  color: ColorsUtils.color6666,
                                  lineHeight: 1.2.h),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 10.h),
                            alignment: Alignment.centerLeft,
                            child: Wrap(
                              spacing: 20.w,
                              crossAxisAlignment: WrapCrossAlignment.center,
                              alignment: WrapAlignment.start,
                              children: [
                                Text(
                                  '100',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize20,
                                      color: ColorsUtils.color0000,
                                      fontWeight: FontWeight.w700),
                                ),
                                Text(
                                  '满105可用',
                                  style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color9999,
                                      fontSize: StylesUtils.fontSize12),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    )),
                SizedBox(
                  width: 100,
                  child: Column(
                    children: [
                      Container(
                        margin: const EdgeInsets.only(top: 10),
                        alignment: Alignment.center,
                        child: SizedBox(
                          width: 51,
                          height: 51,
                          child: CustomPaint(
                            painter: MyCircular(),
                            child: Column(
                              children: [
                                Container(
                                  margin: const EdgeInsets.only(top: 10),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '已抢',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.colorF048,
                                        fontSize: StylesUtils.fontSize10,
                                        fontWeight: FontWeight.w700),
                                  ),
                                ),
                                Container(
                                  alignment: Alignment.center,
                                  margin: const EdgeInsets.only(top: 5),
                                  child: Text(
                                    '23%',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.colorF048,
                                        fontSize: StylesUtils.fontSize10,
                                        fontWeight: FontWeight.w700),
                                  ),
                                )
                              ],
                            ),
                          ),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(top: 10),
                        alignment: Alignment.center,
                        child: Container(
                          alignment: Alignment.center,
                          constraints: const BoxConstraints.expand(width: 78, height: 24),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(12),
                            color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048),
                          ),
                          child: Text(
                            '立即领取',
                            style:
                            StylesUtils.customTextStyle(fontSize: StylesUtils.fontSize12),
                          ),
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          ),
        ),
      ));
    }
    return list;
  }
}